<script setup lang="ts">
import {onMounted, ref} from "vue";

onMounted(()=>{
  screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
})
const screen = ref()

function getScale(w=1920, h=1080) {
  const ww = window.innerWidth / w
  const wh = window.innerHeight /h
  return ww < wh ? ww : wh
}

window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
}
</script>

<template>
  <div class="container">
    <div class="screen" ref="screen">
      <div class="top"></div>
      <div class="bottom"></div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.container {
  width: 100vw;
  height: 100vh;
  background-size: cover;
  .screen {
    position: fixed;
    width: 1920px;
    height: 1080px;
    background: red;
    left: 50%;
    top: 50%;
    transform-origin: left top;

    .top {
      width: 100%;
      height: 40px;
      background: cyan;
    }
  }
}
</style>